//
//  GYListView.m
//  GYDemo
//
//  Created by Mrzhang on 2018/5/10.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYListView.h"
#import "Head.h"


@implementation GYItemModel
@end

@interface GYListView ()
@property(nonatomic,strong)UIImageView* locationIV;
@property(nonatomic,strong)UIImageView* typeIV;
@property(nonatomic,strong)UIImageView* areaIV;
@property(nonatomic,strong)UIImageView* timeIV;


@property(nonatomic,strong)UILabel* arerLab;
@property(nonatomic,strong)UILabel* typeLab;
@property(nonatomic,strong)UILabel* addressLab;
@property(nonatomic,strong)UILabel* timeLab;
@end
@implementation GYListView

-(UIImageView *)locationIV
{
    if (!_locationIV) {
        _locationIV=[[UIImageView alloc] init];
        _locationIV.image=[UIImage imageNamed:@"storage_location"];
        _locationIV.x=0;
        _locationIV.y=0;
        _locationIV.width=_locationIV.image.size.width;
        _locationIV.height=_locationIV.image.size.height;
        
    }
    return _locationIV;
}

-(UIImageView *)typeIV
{
    if (!_typeIV) {
        _typeIV=[[UIImageView alloc] init];
        _typeIV.image=[UIImage imageNamed:@"storage_type"];
        
        _typeIV.y=0;
        _typeIV.width=_typeIV.image.size.width;
        _typeIV.height=_typeIV.image.size.height;
    }
    return _typeIV;
}

-(UIImageView *)areaIV
{
    if (!_areaIV) {
        _areaIV=[[UIImageView alloc] init];
        _areaIV.image=[UIImage imageNamed:@"storage_area"];
        _areaIV.x=0;
        _areaIV.y=self.height-_areaIV.image.size.height;
        _areaIV.width=_areaIV.image.size.width;
        _areaIV.height=_areaIV.image.size.height;
    }
    return _areaIV;
}

-(UIImageView *)timeIV
{
    if (!_timeIV) {
        _timeIV=[[UIImageView alloc] init];
        _timeIV.image=[UIImage imageNamed:@"storage_time"];
        
        _timeIV.y=self.height-_timeIV.image.size.height;
        _timeIV.width=_timeIV.image.size.width;
        _timeIV.height=_timeIV.image.size.height;
    }
    return _timeIV;
}

-(UILabel *)addressLab
{
    if (!_addressLab)
    {
        _addressLab=[[UILabel alloc] init];
        _addressLab.x=_locationIV.x+_locationIV.image.size.width+5;
        _addressLab.y=0;
        _addressLab.width=100;
        _addressLab.height=WFCGFloatY(12);
        _addressLab.font=SYSTEMFONT(11);
        _addressLab.textColor=Main_Color_Black;
        
    }
    return _addressLab;
}


-(UILabel *)typeLab
{
    if (!_typeLab)
    {
        _typeLab=[[UILabel alloc] init];
        
        _typeLab.y=0;
        _typeLab.width=100;
        _typeLab.height=WFCGFloatY(12);
        _typeLab.font=SYSTEMFONT(11);
        _typeLab.textColor=Main_Color_Black;
    }
    return _typeLab;
}


-(UILabel *)arerLab
{
    if (!_arerLab) {
        _arerLab=[[UILabel alloc] init];
        _arerLab.x=_areaIV.image.size.width+5;
        
        _arerLab.width=100;
        _arerLab.height=WFCGFloatY(12);
        _arerLab.font=SYSTEMFONT(11);
        _arerLab.textColor=Main_Color_Black;
    }
    return _arerLab;
}

-(UILabel *)timeLab
{
    if (!_timeLab) {
        _timeLab=[[UILabel alloc] init];
        
        
        _timeLab.width=100;
        _timeLab.height=12;
        _timeLab.font=SYSTEMFONT(11);
        _timeLab.textColor=Main_Color_Black;
    }
    return _timeLab;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor=[UIColor whiteColor];
        [self addSubview:self.locationIV];
        [self addSubview:self.typeIV];
        [self addSubview:self.areaIV];
        [self addSubview:self.timeIV];
        [self addSubview:self.addressLab];
        
        [self addSubview:self.typeLab];
        [self addSubview:self.arerLab];
        [self addSubview:self.timeLab];
        
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    _areaIV.y=self.height-_areaIV.image.size.height;
    _timeIV.y=self.height-_timeIV.image.size.height;
    _arerLab.y=_areaIV.y;
    _timeLab.y=_timeIV.y;
    
    _timeIV.x=self.width/2;
    _typeIV.x=self.width/2;
    _typeLab.x=_typeIV.x+_typeIV.image.size.width+5;
    _timeLab.x=_timeIV.x+_timeIV.image.size.width+5;

}

-(void)setLabText:(GYItemModel *)model
{
    _addressLab.text=model.address;
    _typeLab.text=model.type;
    _arerLab.text=[NSString stringWithFormat:@"%@㎡",model.acreage];
    _timeLab.text=model.createtime;
}
@end
